﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace OPCTreeMonitor.InterfaceWindow
{
    /// <summary>
    /// InterfaceAddWindow.xaml 的交互逻辑
    /// </summary>
    public partial class InterfaceAddWindow : Window
    {
        public event Action<string> GroupAdded;
        private string parentPath;

        public InterfaceAddWindow( string parentPath)
        {
            InitializeComponent();
            Title = $"在 {parentPath} 下添加组";
            this.parentPath = parentPath;
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string groupName = txtAdd.Text.Trim();
            if (string.IsNullOrEmpty(groupName))
            {
                MessageBox.Show("请输入有效的组名。");
                return;
            }
            GroupAdded?.Invoke($"{parentPath}/{groupName}");
            this.Close();
        }
    }
}
